﻿<?PHP
require_once 'framework/util/DataBaseLink.class.php';

class RestauranteDaoImpl
{
	
	private $restaurante = null;
	private $dblink = null;
	private $mysqli = null;
	private $sql = null;

	public function __construct(){
		$this->dblink = new DataBaseLink();
	}
	
	public function insert($restaurante){
		
		$this->sql = "INSERT INTO `restaurante`(
						 `id`,
						 `nome`
						 )
						VALUES (
						 null,
						 '".$restaurante->getNome()."'
						 )";
		$this->mysqli = $this->dblink->getMysqli();
        $query = $this->mysqli->query($this->sql);	
		mysqli_close($this->mysqli);
	
	}
	
	public function remove($restaurante){
		$this->sql = "DELETE FROM `restaurante` WHERE `id` = '".$restaurante->getId()."'";
		$this->mysqli = $this->dblink->getMysqli();
        $query = $this->mysqli->query($this->sql);	
		mysqli_close($this->mysqli);
	}
	
	public function removeAll(){
		$this->sql = "DELETE FROM `restaurante`";
		$this->mysqli = $this->dblink->getMysqli();
        $query = $this->mysqli->query($this->sql);	
		mysqli_close($this->mysqli);
	}
	
	public function getAll(){
		$this->sql = "SELECT * FROM `restaurante`";
		$this->mysqli = $this->dblink->getMysqli();
        $query = $this->mysqli->query($this->sql);	
		mysqli_close($this->mysqli);
		return $query;
	}
	
	public function getById($id){
		$this->sql = "SELECT * FROM `restaurante` where id = ".$id.";";
		$this->mysqli = $this->dblink->getMysqli();
        $query = $this->mysqli->query($this->sql);	
		mysqli_close($this->mysqli);
		return $query;
	}


}

?>